package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApCollectionMapper;
import com.heima.article.service.ApCollectionService;
import com.heima.model.article.pojos.ApCollection;

import org.springframework.stereotype.Service;

@Service
public class ApCollectionServiceImpl extends ServiceImpl<ApCollectionMapper,ApCollection> implements ApCollectionService {

    //根据实体id和文章id查询收藏数据
    @Override
    public ApCollection findCollectionByEntryIdAndArticleId(Integer entryId, Long articleId,Short type) {
        if(entryId!=null && articleId!=null){
            ApCollection apCollection = getOne(Wrappers.<ApCollection>lambdaQuery()
                    .eq(ApCollection::getEntryId, entryId)
                    .eq(ApCollection::getArticleId, articleId)
                    .eq(ApCollection::getType, type));
            return apCollection;
        }

        return null;
    }
}
